//pacifier.txt - This reduces the aggro radius of all nearby hostile creatures 
// when powered up
//Cell 0,1 - A SDF. If both zero, pacifier always works. Otherwise, pacifier 
//    works if SDF is nonzero


beginobjectscript; // mine

variables;

short is_on = FALSE;
short cur_tick;

body;

beginstate INIT_STATE;
	if ((get_memory_cell(0) > 0) || (get_memory_cell(1) > 0)) {
		if (get_sdf(get_memory_cell(0),get_memory_cell(1)) > 0) 
			is_on = TRUE;
		}
		else is_on = TRUE;
	cur_tick = get_current_tick();
			
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; 
	// turn mine off if flag set
	if ((get_memory_cell(0) > 0) || (get_memory_cell(1) > 0)) {
		if (get_sdf(get_memory_cell(0),get_memory_cell(1)) > 0) {
			is_on = TRUE;
			}
		}

	if (is_on) {
		if (tick_difference(cur_tick,get_current_tick()) > 3) {
			cur_tick = get_current_tick();
			pacify_nearby(8,2);
	  		create_missile_spiral(144,20,6,2);
			
			}
		}

break;

beginstate USE_STATE;
	if (is_on) {
		print_str_color("You examine the pacification pylon. It is active.",2);
		print_str_color("  All hostile creatures near it will be pacified. They will only",2);
		print_str_color("  attack you if you get very close to them.",2);
		}
		else {
			print_str_color("You examine the pacification pylon. It is inactive.",2);
			print_str_color("  It will not do anything until you can find a way to restore",2);
			print_str_color("  power to it.",2);
			}
		
break;